package org.hy.user.dao;

import java.util.List;

import org.hibernate.Query;
import org.hy.user.UserModel;
import org.hy.utils.common.dao.BaseDao;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Component;

@Component(value="sysUserDao")
public class UserDao extends BaseDao {
	
	
	protected static final String HQL_LIST = "from UserModel ";
	protected static final String HQL_COUNT = "select count(*) from UserModel ";

	protected static final String HQL_LIST_QUERY_CONDITION = " where name like ?";
	protected static final String HQL_LIST_QUERY_ALL = HQL_LIST + HQL_LIST_QUERY_CONDITION + "order by id desc";
	protected static final String HQL_COUNT_QUERY_ALL = HQL_COUNT + HQL_LIST_QUERY_CONDITION;
	
	
	
	public boolean insertUser(UserModel userModel) {
		try {
			//getSession().getTransaction().begin();
			getSession().save(userModel);
			//getSession().getTransaction().commit();
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			//getSession().getTransaction().rollback();
			return false;
		}
	}
	
	public List<UserModel> queryAllUser(){
		List<UserModel> result = null;
		//getSession().getTransaction().begin();
		//Query query = getSession().createQuery(HQL_LIST);
		//设定HQL中的参数
		//setParameters(query, paramlist);
		//result = query.list();
		//getSession().getTransaction().commit();
		return result;
	}
	

}
